<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">

    <link href="/bootstraptable/bootstrap-table.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <div class="panel-heading" style="text-align: right">
        <button type="button" class="btn btn-default"><a href="javascript:history.back()"
                                                         style="color: black">返回</a></button>
    </div>
    <div class="panel panel-default">
        <form id="module_form" class="form-horizontal">
            <div class="panel-heading">
                <div class="h4" align="center">出库调度单</div>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-4 control-label">出库单编号</label>
                        <div class="col-sm-8">
                            <input type="text" name="payId" id="payId"
                                   class="form-control text_bottom_border">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="col-sm-8 ">
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-4 control-label">出库理由</label>
                        <div class="col-sm-8">
                            <input type="text" name="reason" id="reason"
                                   class="form-control text_bottom_border">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-4 control-label">出库详细理由</label>
                        <div class="col-sm-8 ">
                            <input type="text" name="reasonexact" id="reasonexact"
                                   class="form-control text_bottom_border">
                        </div>
                    </div>
                </div>
            </div>
            <table id="StorageGatherDetails_table"></table>
            <div class="form-group">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">应出库总件数:</label>
                    <div class="col-sm-8">
                        <input type="text" name="amountSum" id="amountSum"
                               class="form-control text_bottom_border" style="background-color: #FFFFFF" readonly
                               value="">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">已出库总件数:</label>
                    <div class="col-sm-8">
                        <input class="form-control" id="paidAmountSum" name="paidAmountSum" style="background-color: #FFFFFF" readonly>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<input type="hidden" id="id">
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>
<!-- 自定义js -->
<script src="/js/hAdmin.js?v=4.1.0"></script>
<!--<script type="text/javascript" src="/js/index.js"></script>-->

<!-- 第三方插件 -->
<script src="/js/plugins/pace/pace.min.js"></script>

<!--BootstrapTable-->
<script src="/bootstraptable/bootstrap-table.min.js"></script>
<script src="/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>
<script>
    $(function(){
     let StoragePayId=localStorage.getItem("StoragePayId");
        $.post("/StoragePay/showById", {"id": StoragePayId}, function (res) {
            $("#payId").val(res.payId)
            $("#id").val(res.id)
            $("#reasonexact").val(res.reasonexact)
            $("#amountSum").val(res.amountSum)
            $("#paidAmountSum").val(res.paidAmountSum)
            $("#reason").val(ruku(res.reason))
        $("#StorageGatherDetails_table").bootstrapTable({
            // 请求方式
            method: "post",
            // 内容类型：如果请求方式是post，内容类型必须是application/x-www-form-urlencoded
            contentType: "application/x-www-form-urlencoded",
            // 请求路径
            url: '/StoragePay/StoragePayDetailsShowById',
            // 数据行交替样式
            striped: true,
            // // 是否是服务器端分页：server表示服务器端，client表示前端分页
            // sidePagination: 'server',
            // //初始化加载第一页
            // pageNumber: 1,
            // //是否分页
            // pagination: true,
            // // 单页记录数，页大小
            // pageSize: 2,
            // // 分页列表
            // pageList: [2, 5, 10, 20],
            //刷新按钮
            // showRefresh:true,
            // 请求参数
            queryParams: function (params) {
                let obj = {
                    // params.limit获取组件中的页大小
                    // params.offset获取请求数据的起始索引
                    // pageSize: params.limit,
                    // pageNo: (params.offset / params.limit) + 1,
                    id: res.id

                }
                return obj;
            },

            // 表格列标题
            columns: [{
                title: "序号",
                field: "id",
            }, {
                title: "产品名称",
                field: "productName",
            }, {
                title: "产品编号",
                field: "productId",
            }, {
                title: "应出库件数",
                field: "amount",
            }, {
                title: "已出库件数",
                field: "paidAmount"
            }, {
                title: "调度",
                field: "",
                formatter: function (value, row, index) {
                    let row1 = JSON.stringify(row)
                    if (row.payTag =="K002-1") {
                        return "<a href='javascript:edit(" + row1 + ")'>调度</a>"
                    } else {
                        return "<a href='javascript:edit11(" + row1 + ")'>完成</a>"
                    }
                }
            }]
        })
    })
    })
    function edit(row1) {
        let productId = row1.productId
        $.post("/StorageCell/productId", {"productId": productId}, function (res) {
            if (res == true) {
                localStorage.setItem("id51", row1.id)
                localStorage.setItem("id52", $("#id").val())
                window.location = "/safe/draw_up_an_outboun_dorde2UI"
            } else {
                window.location = "/safe/anquanUI"
            }
        })
    }


    function ruku(w) {
        if (w == "C002-1")
            return "生产领料"
        else if (w == "C002-2")
            return "赠送"
        else if (w == "C002-3")
            return "内部借领"
        else if (w == "C002-4")
            return "其他借领"
    }
</script>
</body>
</html>